package com.fairytask.ui.skillUnit
{
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.components.comboBox.ComboBox;
	import com.fairytask.engine.components.text.Input;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.event.LogicEvent;
	import com.fairytask.resource.StaticIni;
	import com.fairytask.ui.InfoUI;
	import com.fairytask.ui.base.UnitUI;
	import com.fairytask.ui.equipUnit.EquipPart;
	import com.fairytask.ui.equipUnit.PropertyPart;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	/**
	 * 装备栏属性UI 
	 * @author xujh
	 * 
	 */
	public class SkillProfileUI extends UnitUI
	{
		private static var _self		:SkillProfileUI;
		//=========显示面板====================================================
		//属性数值
//		public var equip_value:Label;	//装备评分
//		public var equip_value_input:Input;//装备评分
		public var propSp		:Sprite = new Sprite();
		public var expLabel	:Clip;	//经验
		public var expInput	:Label;
		public var expBar		:MovieClip;	//经验条
		
		//=============人物部分显示=====================
		public var playerSpace	:Sprite = new Sprite();
		public var nameBg		:MovieClip;
		public var nameLab		:Label;	//姓名
		public var levelLab	:Label;	//等级
		public var titleLab	:Clip;	//称号
		public var titleIpt	:ComboBox;
		public var postLab		:Clip;	//职位
		public var postIpt		:Input;
		
		//装备容器
		private var personEquip :Sprite;
		//人物模型容器
		private var modelSpace	:Sprite	= new Sprite();
		//装备模型容器
		private var weaponSpace:Sprite	= new Sprite();
		
		private var _modelMc	:MovieClip;	//人物模型
		private var _weaponMc	:MovieClip;	//装备模型
		private var _info		:InfoUI		=	InfoUI.getInstance();
		
		//===================记录的数据========================
		//private var _player	:Player		= Player.getInstance();
		private var _lvExp		:int;
		private var _nowExp	:int;
		private var _bindArr	:Array	=[];	//绑定数据的数组，用于解绑
		private var _equipPart	:EquipPart		= new EquipPart();
		private var _propPart	:PropertyPart	= new PropertyPart();
		
		public static function getInstance():SkillProfileUI
		{
			if (_self == null)
			{
				_self=new SkillProfileUI;
			}
			return _self;
		}
		
		public function SkillProfileUI()
		{
			super();
		}
		
		override public function initGUI():void
		{
			windowBG.addChild(_equipPart);
			//初始化宠物人物不同信息显示容器
			propSp.x = 5;
			propSp.y = 105;
			windowBG.addChild(propSp);
			playerSpace.x = 10;
			playerSpace.y = 70;
			windowBG.addChild(playerSpace);
			propSp.addChild(_propPart);
			//初始化装备
			initBind();
			//
			titleIpt.canUse = false;
		}
		
		/**
		 * 添加数据绑定 
		 * 
		 */
		private function initBind():void
		{
			//绑定视图
			//_equipPart.bindView(ViewDefine.VIEWPORT_EQUIP);
			//监听玩家准备完毕
			//model.addEventListener(LogicEvent.USERLOADED, onUserReady);
		}
		
		/**
		 * 绑定玩家数据 
		 */
		private function onUserReady(evt:LogicEvent):void
		{
			/*_bindArr.push([_player.data,"Name",bindManager.BindProp(_player.data, "Name",this,"rName")]);	//名字
			_bindArr.push([_player.data,"Level",bindManager.BindProp(_player.data, "Level",this,"rlevel")]);			//等级
			_bindArr.push([_player.data,"PlayerExp",bindManager.BindProp(_player.data, "PlayerExp",this,"rExp")]);	//经验
			
			_bindArr.push([_player.data,"Model",bindManager.BindProp(_player.data, "Model",_equipPart,"roleModel")]);		//人物模型
			_bindArr.push([_player.data,"WeaponModel",bindManager.BindProp(_player.data, "WeaponModel",_equipPart,"weaponModel")]);//武器模型
			_bindArr.push([_player.data,"WeaponModel",bindManager.BindProp(_player.data, "WeaponLevel",_equipPart,"WeaponLevel")]);//武器特效
			_bindArr.push([_player.data,"Color",bindManager.BindProp(_player.data, "Color",this,"rColor")]);	//获取颜色
			//绑定基本属性
			_propPart.bindProp(_player.data);*/
			
		}
		
		//==========================绑定数据处理=======================================
		//设置名字
		public function set rName(val:String):void
		{
			nameLab.htmlStrByBorder = val;
			nameLab.x = 130 - nameLab.width/2;
		}
		/**
		 * 当前经验 
		 * @param val
		 * 
		 */		
		public function set rExp(val:int):void
		{
			//当前经验
			val > _lvExp ? _nowExp = _lvExp : _nowExp = val;
			expInput.htmlStr = _nowExp + "/" + _lvExp;
			expInput.x = expBar.x + (expBar.width - expInput.width) / 2;
			_lvExp != 0 ? expBar["maskBar"].width = expBar.width * _nowExp / _lvExp : expBar["maskBar"].width = 0;
		}
		
		/**
		 * 设置等级 
		 * @param val
		 * 
		 */
		public function set rlevel(val:int):void
		{
			levelLab.htmlStrByBorder = StaticIni.getSwfLangStr("1000000062") + val;
			levelLab.x = 130 - levelLab.width/2;
			_lvExp = int(StaticIni.getIniVar("lv_" + val,"EXP"));
			expInput.htmlStr = _nowExp + "/" + _lvExp;
			expInput.x = expBar.x + (expBar.width - expInput.width) / 2;
			_lvExp != 0 ? expBar["maskBar"].width = expBar.width * _nowExp / _lvExp : expBar["maskBar"].width = 0;
		}
		
		/**
		 * 称号 
		 * @param val
		 * 
		 */
		public function set rTitle(val:String):void
		{
			titleIpt.dataList = [val];
			titleIpt.setSelected(0);
		}
		//==========================绑定数据处理完毕=======================================
	}
}